#include<bits/stdc++.h>
using namespace std;
int fj(int a){
	int sum = 0;
	for(int i = 2 ; i * i <= a ; i++){
		if(a % i == 0){
			sum = sum + i;
			if(i * i != a){
				sum = sum + a / i;
			}
		}
	}
	return sum;
}
int main(){
	freopen("number.in" , "r" , stdin);
	freopen("number.out" , "w" , stdout);
	int n , sum1 , sum2;
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= n ; j++){
			sum1 = fj(i);
			sum2 = fj(j);
			if(sum1 == j && sum2 == i && i != j){
				cout << i << " " << j << endl;
			}
		}
	}
	return 0;
}